<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Eigenmath Demo</title>
</head>
<body>

<script src="../js/eigenmath.js"></script>

<i>In Safari's Develop menu, the setting Disable Local File Restrictions must be checked.</i>
<br>

<table><tr>

<td>
<textarea id="stdin" rows="24" cols="80" style="font-family:courier;font-size:12pt">
</textarea>
</td>

<td>
<input type="submit" value="selftest1" onclick="readfile('selftest1')">
<br>
<br>
<input type="submit" value="selftest2" onclick="readfile('selftest2')">
<br>
<br>
<input type="submit" value="drawtest" onclick="readfile('drawtest')">
<br>
<br>
<input type="submit" value="chartest" onclick="readfile('chartest')">
<br>
<br>
<input type="file" id="choosefile">
<br>
<br>
<button onclick="run()">Run</button>
</td>

</tr></table>

<p>
<div id="stdout"></div>

<script>

document.getElementById("choosefile").addEventListener("change", choosefile);

function
choosefile()
{
	var f = new FileReader();
	f.onload = function()
	{
		document.getElementById("stdin").value = f.result;
		document.getElementById("stdout").innerHTML = "";
	}
	f.readAsText(this.files[0]);
}

function
readfile(s)
{
	foo = new XMLHttpRequest();
	foo.open('GET', s);
	foo.addEventListener("load", readfile_complete);
	foo.send();
}

function
readfile_complete(event)
{
	document.getElementById("stdin").value = foo.responseText;
	document.getElementById("stdout").innerHTML = "";
}

</script>

</body>
</html>
